package mirrormonkey.commons.transform;

import mirrormonkey.core.server.ServerCoreModule;
import mirrormonkey.framework.SyncAppState;
import mirrormonkey.framework.entity.SyncEntity;

import com.jme3.network.MessageConnection;
import com.jme3.scene.Spatial;

public class ServerTransformUpdateControl extends TransformUpdateControl {

	protected final ServerCoreModule coreModule;

	public ServerTransformUpdateControl(Spatial spatial,
			SyncAppState<?> appState) {
		super(spatial);
		if (!SyncEntity.class.isInstance(spatial)) {
			throw new IllegalArgumentException(
					"Spatial must be assignable to SyncEntity");
		}
		coreModule = appState.getModule(ServerCoreModule.class);
	}

	public void addMessageConnection(MessageConnection connection) {
		coreModule.addMapping(connection, this,
				ClientTransformUpdateControl.class, spatial);
	}

	public void removeMessageConnection(MessageConnection connection) {
		coreModule.removeMapping(connection, this);
	}

}
